package org.gd.hellojson.jackson.tests;

import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectWriter;

import java.io.IOException;

/**
 * @author Gorhover
 * @version 1.0-SNAPSHOT
 * @since 2013-10-30 15:44
 */
class MethodsTest {

    public static void main(String[] args) throws IOException {
        User user = new User();
        user.setId(10);
        user.setName("user name");
        System.out.println();
        ObjectMapper mapper = new ObjectMapper();
        ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
        String json = writer.writeValueAsString(user);
        System.out.println(json);
        user = mapper.readValue(json, User.class);
        System.out.println();
        System.out.println(user);
    }
}
